import Vue from 'vue'
import VueRouter from 'vue-router'
import FirstPage from "@/views/FirstPage"
import Sort from "@/views/Sort"
import Order from "@/views/Order"
import My from "@/views/My"
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/FirstPage'
  },
  {
    path: '/firstpage',
    component: FirstPage,
  },
  {
    path: '/sort',
    component: Sort,
  },
  {
    path: '/order',
    component: Order,
  },
  ,
  {
    path: '/my',
    component: My,
  },
]

const router = new VueRouter({
  routes
})

const isLogin = true
router.beforeEach((to, from, next) => {
  if (to.path === FirstPage && !isLogin) {
    alert('请登录')
    next(false)
  } else {
    next(true)
  }
})

export default router
